#include<bits/stdc++.h>
using namespace std;
int t,n,m,ml,mv,cnt;
struct pos{
    int l,r,vis;
}e[100005];
int p[100005];
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')
            f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
inline void write(int x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9){
        write(x/10);
    }
    putchar(x%10+'0');
    return;
}
int cmp1(pos a,pos b){
    if(a.r==b.r)
        return a.l<b.l;
    return a.r<b.r;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    t=read();
    int d,v,a;
    double x;
    int fx,ans=0,fy,ansx=0;
    while(t--){
        n=read();
        m=read();
        ml=read();
        mv=read();
        cnt=0;
        for(register int i=1;i<=n;++i){
            d=read();
            v=read();
            a=read();
            if(a==0){
                if(v>mv){
                    e[++cnt].l=d;
                    e[cnt].r=ml;
                }
                continue;
            }
            if(a<0&&v<=mv)
                continue;
            if(a>0&&v>mv){
                e[++cnt].l=d;
                e[cnt].r=ml;
                continue;
            }
            if(a>0){
                x=1.0*(mv*mv-v*v)/(2*a);
                fx=x;
                if(fx>x)
                    x++;
                x+=d;
                if(x>ml)
                    continue;
                e[++cnt].l=x;
                e[cnt].r=ml;
                continue;
            }
            a=-a;
            e[++cnt].l=d;
            x=1.0*(v*v-mv*mv)/(2*a);
            fx=x;
            if(fx==x)
                fx--;
            e[cnt].r=min(d+fx,ml);
        }
        for(register int i=1;i<=m;++i)
            p[i]=read();
        sort(e+1,e+cnt+1,cmp1);
        fx=1;
        ans=0;
        for(register int i=1;i<=m;++i){
            if(p[i]<e[fx].l)
                continue;
            while(fx<=cnt&&p[i]>e[fx].r){
                fx++;
            }
            while(fx<=cnt&&p[i]<=e[fx].r&&p[i]>=e[fx].l){
                e[fx].vis=1;
                fx++;
            }
            if(fx>cnt)
                break;
        }
        for(register int i=1;i<=cnt;++i)
            if(e[i].vis==1)
                ans++;
        fx=0;
        p[0]=-1;
        ansx=0;
        p[m+1]=ml+1000005;
        for(register int i=1;i<=cnt;++i){
            if(e[i].vis==0)
                continue;
            if(e[i].r>=p[fx]&&e[i].l<=p[fx])
                continue;
            if(fx==m)
                break;
            while(p[fx+1]<=e[i].r&&fx<=m){
                fx++;
            }
            ansx++;
        }
        write(ans);
        putchar(' ');
        write(m-ansx);
        putchar('\n');
        for(register int i=1;i<=cnt;++i){
            e[i].l=0;
            e[i].r=0;
            e[i].vis=0;
        }
        memset(p,0,sizeof(p));
    }

    return 0;
}
